﻿$(document).ready(function () {
    $('.pie-chart').each(function () {
        var values = [];
        var data = jQuery.parseJSON($('pre', this).text());
        var subset = [];
        $(data, this).each(function () {
            subset.push([this.Key, parseInt(this.Value)]);
        });
        values.push(subset);
        $('pre', this).hide();
        var id = $('div', this).attr('id');
        var plot1 = $.jqplot(id, values, {
            seriesDefaults: {
                renderer: $.jqplot.PieRenderer,
                rendererOptions: {
                    showDataLabels: true
                }
            },
            legend: { show: true, location: 'e' }
        });
    });
});